package pers.xiaojun.boot.module.system.service.dept;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import pers.xiaojun.boot.module.system.dao.entity.dept.UserPostDO;
import pers.xiaojun.boot.module.system.dao.mapper.dept.UserPostMapper;

import java.util.Collection;
import java.util.List;

/**
 * 用户岗位服务实现
 *
 * @author xiaojun
 * @since 2025-11-02
 */
@Service
public class UserPostServiceImpl extends ServiceImpl<UserPostMapper, UserPostDO> implements UserPostService {


    @Override
    public void removeUserPostByUserIdAndPostIds(Long userId, Collection<Long> postIds) {
        this.baseMapper.delete(new LambdaQueryWrapper<UserPostDO>()
                .eq(UserPostDO::getUserId, userId)
                .in(UserPostDO::getPostId, postIds)
        );
    }

    @Override
    public void removeUserPostByPostId(Long postId) {
        this.baseMapper.deleteById(postId);
    }

    @Override
    public void removeUserPostByPostIds(Collection<Long> postIds) {
        this.baseMapper.deleteByIds(postIds);
    }

    @Override
    public List<Long> listPostIdsByUserId(Long userId) {
        return this.baseMapper.selectPostIdsByUserId(userId);
    }
}
